package cn.kgc.vue.controller;

import cn.kgc.vue.commons.QueryCondition;
import cn.kgc.vue.commons.ResponseResult;
import cn.kgc.vue.entity.LogInfo;
import cn.kgc.vue.service.LogInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date 2024/4/20
 * @description
 */
@RestController
@RequestMapping("logs")
@Api(tags = "日志模块")
public class LogInfoController {
    @Resource
    private LogInfoService logInfoService;

    // 日志分页
    @PostMapping("page")
    @ApiOperation("日志分页")
    public ResponseResult logsInfoPage(@RequestBody  QueryCondition<LogInfo> queryCondition) {
        return logInfoService.logsPage(queryCondition);
    }


    // 日志分页
    @DeleteMapping("delete")
    @ApiOperation("删除日志")
    public ResponseResult deleteLogsInfo(@RequestBody List<Integer> ids) {

        logInfoService.removeBatchByIds(ids);
        return  ResponseResult.success().message("删除成功");
    }



    @PostMapping("export")
    @ApiOperation("导出日志")
    public void exportLogsInfo(HttpServletResponse response, @RequestBody Map<String, String> params) {

        logInfoService.exportLogs(response,params);
    }

}
